Photonic crystals constructed from porous Si and other materials may be achieved by a computer-controlled electrochemical etch process. Films of porous Si photonic crystals and other materials may be converted into coded small particles (so-called “smart dust”), and the “smart dust” particles may in turn provide for a host of applications, such as chemical and biological sensing, high-throughput screening, controlled-release drug delivery, and many other uses. In vivo applications are possible with benign materials such as silicon, and other materials including semiconductors and insulators may be used for encoding. In addition to the coded “smart dust,” other types of photonic crystals have applications in sensing, detection and other uses.